import { Local } from '@/utils/storage';
import {getInfo} from '@/api/login';
const userInfosModule = {
	namespaced: true,
	state: {
		userInfos: {},
	},
	mutations: {
		// 设置用户信息
		getUserInfos(state, data) {
			state.userInfos = data;
		},
	},
	actions: {
		// 设置用户信息
		async setUserInfos({ commit }) {
            const userInfos = await getInfo()
            // 存储用户信息到浏览器缓存
            Local.set('userInfo', userInfos);
            commit('getUserInfos', userInfos);
            return userInfos
		},
	},
};

export default userInfosModule;
